package com.example.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@RequestMapping(value = "/hello")
/**
 * controller
 */
@Controller
public class HelloController {

    @RequestMapping(method = RequestMethod.GET, value = "/say")
    @ResponseBody
    public String say(@RequestParam(required = false, defaultValue = "dolphin") String name) {
        String result = "你好:" + (name == null ? "" : name);
        System.out.println("当前时间:" + new Date() + ",result:" + result);
        return result;
    }
}
